<template>
	<view class="member page bgf7 c00">
		<image class="w-20 bg" src="/static/img/bg/home_bg.png"></image>
		<view class="aliC title pb20 cff" :style="{paddingTop: statusBar + 'px'}">管理端</view>
		<view class="flex flexC px16 cff box" @click="goDetail">
			<button class="">
				<image class="w44 borff r50" :src="logo" mode="aspectFill"></image>
			</button>
			<view class="flex1 pl12">
				<view class="fs17 bold6 flex flexC">
					<text>{{username}}</text>
					<text class="bgff c41 px6 r2 ml4 fs10">{{role}}</text>
				</view>
				<button class="cff aliL fs14 dinline mt4">{{mobile}}</button>
			</view>
			<image class="w18" src="/static/img/icon/right_nor.png" mode="widthFix"></image>
		</view>
		<view class="bgff mx15 px35 box r7 py24 mt12 shadow" @click="withDraw">
			<view class="fs16">账户余额</view>
			<view class="flex flexC flexB">
				<view class="bold6 fs24 c00">{{balance}}</view>
				<view class="bg41 r40 px8 py4 fs14">
					<text>今日收益</text>
					<text class="bold6 ml4">{{todayProfit}}</text>
				</view>
			</view>
			<view class="flex flexC flexB aliC mt25">
				<view>
					<view class="">本月收益(元)</view>
					<view class="bold6 fs20">{{monthProfit}}</view>
				</view>
				<view>
					<view class="">上月收益(元)</view>
					<view class="bold6 fs20">{{lastMonthProfit}}</view>
				</view>
			</view>
		</view>
		<!-- <swiper autoplay circular class="bgImg my8 m15">
			<swiper-item :key="index">
				<image src="https://img.quexiaqp.com/banner1.jpg" class="w-20" mode="widthFix"></image>
			</swiper-item>
			<swiper-item :key="index">
				<image src="https://img.quexiaqp.com/banner2.jpg" class="w-20" mode="widthFix"></image>
			</swiper-item>
		</swiper> -->
		<view class="flex flexC bgff r7 px25 py20  m15" @click="kf">
			<image class="w34" src="/static/img/icon/kf.png" mode="aspectFill"></image>
			<view class="flex1 ml16">在线客服</view>
		</view>
		<view v-if="role != '助教'  &&  role != '投资人'" class="flex flexC bgff r7 px25 py20 m15" @click="clickOrder">
			<image class="w34" src="/static/img/icon/mine_cart.png" mode="aspectFill"></image>
			<view class="flex1 ml16">采购订单</view>
		</view>
		<tabbar></tabbar>
	</view>
</template>

<script>
	const statusBar = uni.getSystemInfoSync().statusBarHeight + 10;
	export default {
		data() {
			return {
				statusBar,
				tel: '',
				username: '',
				mobile: '',
				logo: '',
				balance: 0,
				todayProfit: 0,
				monthProfit: 0,
				lastMonthProfit: 0,
				role: '',
				shop:''
			};
		},
		onLoad() {

			this.role = uni.getStorageSync("role");
		},
		onShow() {
			this.username = uni.getStorageSync("username");
			this.mobile = uni.getStorageSync("mobile");
			var shopCache = uni.getStorageSync("selectShop");
			if (shopCache != '') {
				var shop = JSON.parse(shopCache);
				this.shop = shop;
				this.logo = shop.logo;
			}
			this.getInfo();


		},
		methods: {

			clickOrder() {
				uni.navigateTo({
					url: '/other/cai/orderList'
				})
			},

			goDetail() {
				uni.navigateTo({
					url: '/other/member/detail'
				})
			},

			withDraw() {
				
				if(this.role == '投资人') return;
				// uni.navigateTo({
				// 	url: '/other/member/cashIndex?id='+this.shop.id
				// })
				if(this.role == '代理商'){
					uni.navigateTo({
						url: '/other/member/cashIndex'
					})
				}else{
					uni.navigateTo({
						url: '/other/member/data?id='+this.shop.id
					})
				}
			
			},

			share() {
				uni.navigateTo({
					url: '/other/member/poster'
				})
			},

			kf() {


				uni.makePhoneCall({
					phoneNumber: "4001073188"
				})
			},

			getInfo() {

				let that = this;
				let param = {
					role: this.role,
					shop_id:this.shop.id
				};

				this.$api.userInfo(param).then(res => {

					if (res.code == 1) {

						that.username = res.data.username;
						that.mobile = res.data.mobile;
						that.tel = res.data.tel;
						that.balance = res.data.balance;
						that.todayProfit = res.data.todayProfit;
						that.monthProfit = res.data.monthProfit;
						that.lastMonthProfit = res.data.lastMonthProfit;
					} else {
						uni.showToast({
							title: res.msg,
							icon: 'none'
						});
					}

				})
			}
		}

	}
</script>

<style lang="scss" scoped>
	.member {
		.bg {
			position: absolute;
			top: 0;
			left: 0;
			z-index: 0;
		}

		.box,
		.title {
			position: relative;
		}

		.w44 {
			width: 88rpx;
			height: 88rpx;
		}

		.borff {
			border: 4rpx solid #fff;
		}

		.w18 {
			width: 18rpx;
			height: 18rpx;
		}

		.w34 {
			width: 68rpx;
			height: 68rpx;
		}
	}
</style>